import instance from "@/request/request"
import qs from "qs"
import { LocationQueryValue } from "vue-router"
// 获取秒杀活动列表
export const getFlashListApi = (params: any): RES<ITableResult<IFlashList>> => instance.get("/flash/list", { params })

// 修改上下线状态
export const updateFlashStatusApi = (id: number, status: number): RES<number> => instance.post(`/flash/update/status/${id}?status=${status}`)

// 秒杀活动场次
export const getFlashSessionApi = (): RES<ITableResult<IFlashSession>> => instance.get("/flashSession/list",)

// 人气推荐分页查询推荐
export const homeRecommendProductListApi = (params: IHomeHotListParams): RES<IHomeHotListModel> =>
    instance.get("/home/recommendProduct/list", { params });

// 人气推荐批量删除推荐
export const homeRecommendProductDeleteApi = (ids: number[]): RES<number> =>
    instance.post(`/home/recommendProduct/delete?ids=${ids.join(',')}`);

// 人气推荐批量修改推荐状态
export const recommendProductUpdateStatusApi = (ids: number[], recommendStatus: number): RES<number> =>
    instance.post(`/home/recommendProduct/update/recommendStatus?ids=${ids.join(',')}&recommendStatus=${recommendStatus}`);

// 人气推荐修改推荐排序
export const updateSortApi = (id: number, sort: number): RES<number> =>
    instance.post(`/home/recommendProduct/update/sort/${id}?sort=${sort}&id=${id}`);

// 人气推荐查询商品
export const queryProductListApi = (params: IQueryProductListParams): RES<IHomeHotListModel> =>
    instance.get("/product/list", { params })

// 人气推荐添加首页推荐
export const recommendProductCreateApi = (params: HomeHotList): RES<{}> => instance.post("/home/recommendProduct/create", params)

// 添加活动
export const addFlashApi = (params: IFlashList): RES<IFlashList> => instance.post("/flash/create", params)

// 获取全部可选场次及其数量
export const getSelectFlashListApi = (id: number
): RES<IFlashSession> => instance.get(`/flashSession/selectList?flashPromotionId=${id}`)

// 编辑活动
export const editFlashApi = (params: IFlashList): RES<number> => instance.post(`/flash/update/${params.id}`, params)

// 删除活动
export const deleteFlashApi = (id: number): RES<number> => instance.post(`/flash/delete/${id}`)

// 不同场次关联及商品信息
export const getFlashProductListApi = (params: any): RES<ITableResult<IFlashProduct>> => instance.get(`/flashProductRelation/list`, { params })

// 查询商品
export const getProductList = (params: any): RES<ITableResult<IProduct>> => instance.get("/product/list", { params })


// 批量选择商品添加关联
export const addProductRelationApi = (params: any): RES<IFlashProduct> => instance.post("/flashProductRelation/create", [params])

// 修改秒杀商品信息
export const updateFlashRelationApi = (params: any) => instance.post(`/flashProductRelation/update/${params.id}`, params)

// 删除秒杀商品关联
export const deleteFlashRelationApi = (id: number): RES<number> => instance.post(`/flashProductRelation/delete/${id}`)

// 秒杀时间段列表状态
export const updateFlashSessionStatusApi = (id: number, status: number): RES<number> => instance.post(`/flashSession/update/status/${id}?status=${status}`)

// 添加秒杀时间段场次
export const addFlashSessionApi = (params: IFlashSession): RES<IFlashSession> => instance.post("/flashSession/create", params)

//修改秒杀活动场次
export const updateFlashSessionApi = (params: IFlashSession): RES<IFlashSession> => instance.post(`/flashSession/update/${params.id}`, params)

// 删除秒杀活动场次
export const deleteFlashSessionApi = (id: number): RES<number> => instance.post(`/flashSession/delete/${id}`)


// 专题推荐分页查询推荐
export const homeRecommendSubjectListApi = (params: IHomeHotListParams): RES<IHomeHotListModel> =>
    instance.get("/home/recommendSubject/list", { params });

// 专题推荐批量删除推荐
export const homeRecommendSubjectDeleteApi = (ids: number[]): RES<{}> =>
    instance.post(`/home/recommendSubject/delete?ids=${ids.join(',')}`,);

// 专题推荐批量修改推荐状态
export const recommendSubjectUpdateStatusApi = (ids: number[], recommendStatus: number): RES<number> =>
    instance.post(`/home/recommendSubject/update/recommendStatus?ids=${ids.join(',')}&recommendStatus=${recommendStatus}`);

// 专题推荐修改推荐排序
export const subjectUpdateSortApi = (id: number, sort: number): RES<number> =>
    instance.post(`/home/recommendSubject/update/sort/${id}?sort=${sort}&id=${id}`);

// 专题推荐查询商品
export const querySubjectListApi = (params: IQueryProductListParams): RES<IHomeHotListModel> =>
    instance.get("/subject/list", { params })

// 专题推荐添加首页推荐
export const recommendSubjectCreateApi = (params: HomeHotList): RES<{}> => instance.post("/home/recommendSubject/create", params)


// 品牌推荐分页查询推荐
export const homeBrandListApi = (params: IHomeHotListParams): RES<IHomeHotListModel> =>
    instance.get("/home/brand/list", { params });

// 品牌推荐批量删除推荐
export const homeBrandDeleteApi = (ids: number[]): RES<{}> =>
    instance.post(`/home/brand/delete?ids=${ids.join(',')}`,);

// 品牌推荐批量修改推荐状态
export const BrandUpdateStatusApi = (ids: number[], recommendStatus: number): RES<number> =>
    instance.post(`/home/brand/update/recommendStatus?ids=${ids.join(',')}&recommendStatus=${recommendStatus}`);

// 品牌推荐修改推荐排序
export const BrandUpdateSortApi = (id: number, sort: number): RES<number> =>
    instance.post(`/home/brand/update/sort/${id}?sort=${sort}&id=${id}`);

// 品牌推荐查询商品
export const queryBrandListApi = (params: IQueryProductListParams): RES<IHomeHotListModel> =>
    instance.get("/product/list", { params })

// 品牌推荐添加首页推荐
export const BrandCreateApi = (params: HomeHotList): RES<{}> => instance.post("/home/brand/create", params)



// 新品推荐分页查询推荐
export const homeNewProductListApi = (params: IHomeHotListParams): RES<IHomeHotListModel> =>
    instance.get("/home/newProduct/list", { params });

// 新品推荐批量删除推荐
export const homeNewProductDeleteApi = (ids: number[]): RES<{}> =>
    instance.post(`/home/newProduct/delete?ids=${ids.join(',')}`,);

// 新品推荐批量修改推荐状态
export const NewProductUpdateStatusApi = (ids: number[], recommendStatus: number): RES<number> =>
    instance.post(`/home/newProduct/update/recommendStatus?ids=${ids.join(',')}&recommendStatus=${recommendStatus}`);

// 新品推荐修改推荐排序
export const NewProductUpdateSortApi = (id: number, sort: number): RES<number> =>
    instance.post(`/home/newProduct/update/sort/${id}?sort=${sort}&id=${id}`);

// 新品推荐查询商品
export const queryNewProductListApi = (params: IQueryProductListParams): RES<IHomeHotListModel> =>
    instance.get("/product/list", { params })

// 新品推荐添加首页推荐
export const NewProductCreateApi = (params: HomeHotList): RES<{}> => instance.post("/home/newProduct/create", params)



// 广告列表分页查询广告
export const homeAdvertiseListApi = (params: IHomeHotListParams): RES<IHomeHotListModel> =>
    instance.get("/home/advertise/list", { params });

// 广告列表修改上下线状态
export const advertiseUpdateStatusApi = (id: number, status: number): RES<number> =>
    instance.post(`/home/advertise/update/status/${id}?status=${status}`);

// 广告列表删除广告
export const homeAdvertiseDeleteApi = (ids: number[]): RES<{}> =>
    instance.post(`/home/advertise/delete?ids=${ids.join(',')}`,);

// 广告列表获取广告详情
export const homeAdvertiseAddApi = (id: string | LocationQueryValue[]): RES<HomeAdvertiseList> =>
    instance.get(`/home/advertise/${id}`);

// 广告列表添加广告
export const homeAdvertiseCreateApi = (params: HomeAdvertiseList): RES<HomeAdvertiseList> =>
    instance.post("/home/advertise/create", params);

// 广告列表修改广告
export const homeAdvertiseUpdateApi = (params: HomeAdvertiseList): RES<HomeAdvertiseList> =>
    instance.post(`/home/advertise/update/${params.id}`, params);

//根据优惠券名称和类型分页获取优惠券列表
export const getCouponListApi = (params: any): RES<ITableResult<ICouponList>> => instance.get("/coupon/list", { params })

//获取单个优惠券的详细信息
export const getCouponApi = (id: number): RES<ICoupon> => instance.get(`/coupon/${id}`)

//根据优惠券id，使用状态，订单编号分页获取领取记录
export const getCouponHistoryApi = (params: any): RES<ITableResult<ICouponHistory>> => instance.get(`/couponHistory/list`, { params })

// 查询所有一级分类及子分类
export const getProductCategoryChildApi = (): RES<IProductCategoryWithChildren[]> => instance.get("/productCategory/list/withChildren")

//根据商品名称或货号模糊查询
export const getProductSimpleListApi = (params: any): RES<IProductSimpleList[]> => instance.get(`/product/simpleList?keyword=${params}`)

//删除优惠券
export const delCouponApi = (id: number): RES<number> => instance.post(`/coupon/delete/${id}`)

//添加优惠券
export const addCouponApi = (params: any): RES<ICoupon[]> => instance.post('/coupon/create', params)

//修改优惠券
export const updateCouponApi = (params: any): RES<ICoupon[]> => instance.post(`/coupon/update/${params.id}`, params)

